package main

import (
	"fmt"
	"crypto/sha256"
	"io"
	"encoding/base64"
	"math/rand"
	"time"
	"math"
	)

const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 abcdefghijklmnopqrstuvwxyz"
const maxlen = 50
const numbytes = 7
var numstrings = int64(math.Pow(2,25))

func lame_hash(s string) string {
	h := sha256.New()
	io.WriteString(h, s)
	x := h.Sum(nil)[(32-numbytes):]
	x[0] = x[0]&3
	return base64.StdEncoding.EncodeToString(x)
}

func rand_string() string {
	buf := make([]byte, maxlen)
	for i := range buf {
		buf[i] = chars[rand.Intn(len(chars))]
	}
	return string(buf)
}
	
func main() {
	t := time.Now()
	rand.Seed(t.UnixNano())
	fmt.Println("Generating", numstrings, "strings and hashes")
	for i := int64(0); i<numstrings; i++ {
		s := rand_string()
		x := lame_hash(s)
		fmt.Println(s, x)
		fmt.Println(s, x)
	}
}
